home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c-part1 / 6225 < prev    next >
Encoding:
Internet Message Format  |  1996-08-05  |  1.3 KB

  1. Path: erich.triumf.ca!bennett
  2. From: bennett@erich.triumf.ca (P.Bennett)
  3. Newsgroups: comp.lang.c
  4. Subject: Re: HELP: Illegal Pointer Arithmetic
  5. Date: 22 Feb 1996 23:04 PST
  6. Organization: TRIUMF: Tri-University Meson Facility
  7. Distribution: world
  8. Message-ID: <22FEB199623041372@erich.triumf.ca>
  9. References: <4gj0ug$730@news.one.net>
  10. NNTP-Posting-Host: erich.triumf.ca
  11. News-Software: VAX/VMS VNEWS 1.50    
  12.  
  13. In article <4gj0ug$730@news.one.net>, Oren Levin <oren@one.net> writes...
  14. >The following code is giving me a "illegal pointer arithmetic" error.
  15. >I'm trying to strip the carrage return off of a line of text read from a
  16. >file.
  17. >            /* get rid of the trailing carrage return */
  18. >            buffer [strlen (buffer) - 1] = "\0";
  19.  
  20. try
  21.     buffer[strlen(buffer)-1] = '\0'
  22.  
  23. "\0" is a string (a very peculiar one, but still a string) consisting of the
  24. zero byte you specify, plus the usual zero byte that terminates C strings. '\0'
  25. is a single character.
  26.  
  27.  
  28. Peter Bennett VE7CEI                | Vessels shall be deemed to be in sight
  29. Internet: bennett@triumf.ca         | of one another only when one can be
  30. Packet: ve7cei@ve7kit.#vanc.bc.ca   | observed visually from the other
  31. TRIUMF, Vancouver, B.C., Canada     |                          ColRegs 3(k)
  32. GPS and NMEA info and programs: ftp://sundae.triumf.ca/pub/peter/index.html
  33.  
  34.